package com.Luooh.adapter;

import java.util.List;
import java.util.Map;

import com.Luooh.weather.R;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class LifeAdapter extends BaseAdapter 
{
	private Context context;
	private String keys[] = {"chuanyi","ganmao","kongtiao","wuran","xiche","yundong", "ziwaixian"};
	private Map<String, List<String>> map;
	
	public LifeAdapter(Context context, Map<String, List<String>> map){
		this.context = context;
		this.map = map;
	}
	
	public int getCount() {
		return keys.length;
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) 
	{
		ViewHolder holder = null;
		if(convertView == null){
			holder = new ViewHolder();
			convertView = View.inflate(context, R.layout.activity_life_item, null);
			holder.iv_life_ico = (ImageView) convertView.findViewById(R.id.iv_life_ico);
			holder.tv_life_action = (TextView) convertView.findViewById(R.id.tv_life_action);
			holder.tv_life_status = (TextView) convertView.findViewById(R.id.tv_life_status);
			holder.tv_life_sugest = (TextView) convertView.findViewById(R.id.tv_life_sugest);
			convertView.setTag(holder);
		}else {
			holder = (ViewHolder) convertView.getTag();
		}
		holder.tv_life_action.setText(keys[position]);
		holder.tv_life_status.setText(map.get(keys[position]).get(0));
		holder.tv_life_sugest.setText(map.get(keys[position]).get(1));
		return convertView;
	}
		
	class ViewHolder
	{
		ImageView iv_life_ico;
	    TextView tv_life_action;
		TextView tv_life_status;
		TextView tv_life_sugest;
	}
}
